Skip to content

Add UI component demos to the docs site#11397

Open
brophdawg11 wants to merge 21 commits into
mainfrom
agents/ui-component-demos-implementation
Open

Add UI component demos to the docs site#11397
brophdawg11 wants to merge 21 commits into
mainfrom
agents/ui-component-demos-implementation

Conversation

@brophdawg11
Copy link
Copy Markdown
Contributor

@brophdawg11 brophdawg11 commented May 13, 2026

⚠️ #11402 needs to be merged first

Adds component Examples to the API docs site

Can run locally with cd docs; pnpm run docs; pnpm run dev

  • Examples are discovered from packages/ui/**/demos/*.demo.tsx files
  • Demo files are expected to export a default component to be rendered
  • Default components should have a JSDoc block with@name/@description tags that will be rendered above the example
  • Demo files should be entirely self contained so the user can see all aspects of the demo
    • They should only import things from @remix-run/* packages - no local/relative files
  • The displayed source code listing:
    • Rewrites @remix-run/* imports → remix/* so readers see the published package path
    • Strips the @name/@description JSDoc block (already shown as the page header)
    • Runs through Prettier with printWidth: 70 for narrower rendering
Screenshot 2026-05-13 at 12 36 44 PM

brophdawg11 and others added 4 commits May 13, 2026 10:40
Discover *.demo.tsx files under packages/ui/src/components/*/demos/,
parse @name and @description JSDoc metadata via the TypeScript compiler
API, pre-compile each demo with esbuild (jsxImportSource: remix/ui) into
docs/build/demos/, and render a per-demo page with the live component
above a Prettier-formatted, Shiki-highlighted source listing under a
shared rounded frame. Source listings rewrite @remix-run/* imports to
remix/* so readers see the public package paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers home, top-level + subpackage overview pages, one of each API
type (Type/Interface/Class/Function/Variable/Mixin), the button basic
demo (live preview + Prettier-formatted source listing with rewritten
imports and stripped JSDoc), and the not-found shell. Skipped at the
top-level describe for now because the tests require docs/build/md to
exist, which isn't always true in CI. Also wires up a 404 status on
the docs route's not-found response.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
walkDemoFiles now recurses through packages/ui/src/components/ and only
picks up *.demo.tsx files that are direct children of a demos/
directory, matching the path shape that getDemoPackageName already
enforces. Files outside a demos/ folder are silently ignored.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@@ -0,0 +1,29 @@
import { css } from '@remix-run/ui'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example demo file copied from the existing ui/demo app

@github-actions
Copy link
Copy Markdown
Contributor

Preview Build Available

A preview build has been created for this PR. You can install it using:

pnpm install "remix-run/remix#preview/pr-11397&path:packages/remix"

This preview build will be updated automatically as you push new commits.

brophdawg11 and others added 10 commits May 13, 2026 12:59
- Add client-side hydration for demo components via clientEntry + esbuild browser bundles
- Add import map with a single shared remix-ui.js asset for all @remix-run/ui/* and remix/ui/* specifiers, shared across demos and entry.js
- Externalize remix/ui from the docs entry.js build (--external flag)
- Add `@order` JSDoc tag support to control demo sidebar sort order
- Generate markdown alternate response for demo pages (name H1, description, fenced tsx source)
- Add nofollow robots meta to demo pages to prevent crawling of example links
- Add modulepreload for remix-ui.js and per-demo assets to avoid FOUC on client nav
- Key ExampleComponent on demo slug to force full remount between demos

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adopt server styles by refcount instead of resetting the adopted
stylesheet on every reload. DOM preserved across a reload (e.g. inside a
still-hydrated client-entry boundary) keeps its rules until the new
module finishes loading and the virtual root re-renders.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@brophdawg11
Copy link
Copy Markdown
Contributor Author

Note: Revert 34d6a83 once #11402 lands and we can merge main into here

@brophdawg11 brophdawg11 marked this pull request as draft May 14, 2026 21:19
brophdawg11 and others added 4 commits May 15, 2026 09:06
Replaces the three demos.tsx esbuild steps (per-demo server transform,
per-demo browser transform, per-subpath @remix-run/ui bundling) with one
asset-server (remix/assets) that resolves bare specifiers via
package.json exports and compiles TS/TSX on demand. Splits demo source
copy+rewrite into a build step (build:demos), serves docs/build/public
via staticFiles middleware, emits transitive <link rel=modulepreload>
for the client entry, and post-processes the prerender output to rename
.ts/.tsx/.jsx to .js (GitHub Pages will not serve them as JS).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@brophdawg11 brophdawg11 marked this pull request as ready for review May 15, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant